package model

import (
	"time"

	"gorm.io/gorm"
)

type StepDefinition struct {
	Name  string `yaml:"name"`
	Alias string `yaml:"alias"`
	Type  string `yaml:"type"`
	Code  string `yaml:"code"`
}

type InputDefinition struct {
	Name  string `yaml:"name"`
	Type  string `yaml:"type"`
	Value string `yaml:"value"`
}

type WorkflowDefinition struct {
	Name   string            `yaml:"name"`
	Desc   string            `yaml:"desc"`
	Inputs []InputDefinition `yaml:"inputs"`
	Steps  []StepDefinition  `yaml:"steps"`
}

type Workflow struct {
	ID         uint           `gorm:"primarykey" json:"id"`
	CreatedAt  time.Time      `json:"created_at"`
	UpdatedAt  time.Time      `json:"updated_at"`
	DeletedAt  gorm.DeletedAt `gorm:"index" json:"deleted_at"`
	Name       string         `json:"name"`
	Desc       string         `json:"desc"`
	Definition string         `json:"definition"`
}

type WorkflowHistory struct {
	ID         uint           `gorm:"primarykey" json:"id"`
	CreatedAt  time.Time      `json:"created_at"`
	UpdatedAt  time.Time      `json:"updated_at"`
	DeletedAt  gorm.DeletedAt `gorm:"index" json:"deleted_at"`
	WorkflowID uint           `json:"workflow_id"`
	Status     string         `json:"status"`
	Name       string         `json:"name"`
	Desc       string         `json:"desc"`
	Definition string         `json:"definition"`
	Steps      []StepHistory  `json:"steps"`
}

type StepHistory struct {
	ID                uint           `gorm:"primarykey" json:"id"`
	CreatedAt         time.Time      `json:"created_at"`
	UpdatedAt         time.Time      `json:"updated_at"`
	DeletedAt         gorm.DeletedAt `gorm:"index" json:"deleted_at"`
	WorkflowHistoryID uint           `json:"workflow_history_id"`
	Name              string         `json:"name"`
	Alias             string         `json:"alias"`
	Type              string         `json:"type"`
	Code              string         `json:"code"`
	Index             int            `json:"index"`
	Status            string         `json:"status"`     // 状态
	Input             string         `json:"input"`      // 输入
	Output            string         `json:"output"`     // 输出
	ErrOutput         string         `json:"err_output"` // 错误输出
}
